/**
 * 
 */
package com.jolestar.yayaweibotong.dao;

import java.util.Date;
import weibo4j.DirectMessage;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.KeyFactory;
import com.jolestar.yayaweibotong.ServiceType;

/**
 * @author <a href="mailto:jolestar@gmail.com">Jolestar</a>
 */
public class DirectMessageDomain  extends AbstractDomain{

    public static final String TEXT_PROPERTY = "text";
    public static final String SENDER_ID_PROPERTY = "sender_id";
    public static final String RECIPIENT_ID_PROPERTY = "recipient_id";
    public static final String CREATED_AT_PROPERTY = "created_at";
    /**
     * 是否处理过该消息
     */
    public static final String IS_HANDLED_PROPERTY = "is_handled";
    
    /**
     * 
     */
    public DirectMessageDomain(ServiceType serviceType,String id,int sendId,int recipientId,String text,Date createdAt) {
    	super(serviceType,id);
        this.setSenderId(sendId);
        this.setRecipientId(recipientId);
        this.setText(text);
        this.setCreatedAt(createdAt);
        this.setHandled(false);
    }
    
    public String getText() {
        return this.get(TEXT_PROPERTY);
    }
    
    public void setText(String text) {
        this.entity.setProperty(TEXT_PROPERTY, text);
    }

    public int getSenderId() {
        return this.get(SENDER_ID_PROPERTY, 0);
    }
    
    public void setSenderId(int senderId) {
        this.entity.setProperty(SENDER_ID_PROPERTY, senderId);
    }

    public int getRecipientId() {
        return this.get(RECIPIENT_ID_PROPERTY, 0);
    }
    
    public void setRecipientId(int recipientId) {
        this.entity.setProperty(RECIPIENT_ID_PROPERTY, recipientId);
    }
    
    public Date getCreatedAt() {
        return this.get(CREATED_AT_PROPERTY);
    }
    
    public void setCreatedAt(Date date) {
        this.entity.setProperty(CREATED_AT_PROPERTY, date);
    }
    
    public boolean isHandled() {
	return this.get(IS_HANDLED_PROPERTY, false);
    }
    
    public void setHandled(boolean handled) {
	this.entity.setProperty(IS_HANDLED_PROPERTY, handled);
    }
}
